home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / share / dejagnu / framework.exp < prev    next >
Encoding:
Text File  |  1998-12-04  |  21.3 KB  |  888 lines

  1. # Copyright (C) 92, 93, 94, 95, 1996, 1997 Free Software Foundation, Inc.
  2.  
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with this program; if not, write to the Free Software
  13. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14.  
  15. # Please email any bugs, comments, and/or additions to this file to:
  16. # bug-dejagnu@prep.ai.mit.edu
  17.  
  18. # This file was written by Rob Savoye. (rob@cygnus.com)
  19.  
  20. # These variables are local to this file.
  21. # This or more warnings and a test fails.
  22. set warning_threshold 3
  23. # This or more errors and a test fails.
  24. set perror_threshold 1
  25.  
  26. proc mail_file { file to subject } {
  27.     if [file readable $file] {
  28.     catch "exec mail -s \"$subject\" $to < $file"
  29.     }
  30. }
  31.  
  32. #
  33. # Open the output logs
  34. #
  35. proc open_logs { } {
  36.     global outdir
  37.     global tool
  38.     global sum_file
  39.     
  40.     if { ${tool} ==  "" } {
  41.     set tool testrun
  42.     }
  43.     catch "exec rm -f $outdir/$tool.sum"
  44.     set sum_file [open "$outdir/$tool.sum" w]
  45.     catch "exec rm -f $outdir/$tool.log"
  46.     log_file -a "$outdir/$tool.log"
  47.     verbose "Opening log files in $outdir"
  48.     if { ${tool} ==  "testrun" } {
  49.     set tool ""
  50.     }
  51. }
  52.  
  53.  
  54. #
  55. # Close the output logs
  56. #
  57. proc close_logs { } {
  58.     global sum_file
  59.     
  60.     catch "close $sum_file"
  61. }
  62.  
  63. #
  64. # Check build host triplet for pattern
  65. #
  66. # With no arguments it returns the triplet string.
  67. #
  68. proc isbuild { pattern } {
  69.     global build_triplet
  70.     global host_triplet
  71.     
  72.     if ![info exists build_triplet] {
  73.     set build_triplet ${host_triplet}
  74.     }
  75.     if [string match "" $pattern] {
  76.     return $build_triplet
  77.     }
  78.     verbose "Checking pattern \"$pattern\" with $build_triplet" 2
  79.     
  80.     if [string match "$pattern" $build_triplet] {
  81.     return 1
  82.     } else {
  83.     return 0
  84.     }
  85. }
  86.  
  87. #
  88. # Is $board remote? Return a non-zero value if so.
  89. #
  90. proc is_remote { board } {
  91.     global host_board;
  92.     global target_list;
  93.  
  94.     verbose "calling is_remote $board" 3;
  95.     # Remove any target variant specifications from the name.
  96.     set board [lindex [split $board "/"] 0];
  97.  
  98.     # Map the host or build back into their short form.
  99.     if { [board_info build name] == $board } {
  100.     set board "build";
  101.     } elseif { [board_info host name] == $board } {
  102.     set board "host";
  103.     }
  104.  
  105.     # We're on the "build". The check for the empty string is just for
  106.     # paranoia's sake--we shouldn't ever get one. "unix" is a magic
  107.     # string that should really go away someday.
  108.     if { $board == "build" || $board == "unix" || $board == "" } {
  109.     verbose "board is $board, not remote" 3;
  110.     return 0;
  111.     }
  112.  
  113.     if { $board == "host" } {
  114.     if { [info exists host_board] && $host_board != "" } {
  115.         verbose "board is $board, is remote" 3;
  116.         return 1;
  117.     } else {
  118.         verbose "board is $board, host is local" 3;
  119.         return 0;
  120.     }
  121.     }
  122.  
  123.     if { $board == "target" } {
  124.     global current_target_name
  125.  
  126.     if [info exists current_target_name] {
  127.         # This shouldn't happen, but we'll be paranoid anyway.
  128.         if { $current_target_name != "target" } {
  129.         return [is_remote $current_target_name];
  130.         }
  131.     }
  132.     return 0;
  133.     }
  134.     if [board_info $board exists isremote] {
  135.     verbose "board is $board, isremote is [board_info $board isremote]" 3;
  136.     return [board_info $board isremote];
  137.     }
  138.     return 1;
  139. }
  140. #
  141. # If this is a canadian (3 way) cross. This means the tools are
  142. # being built with a cross compiler for another host.
  143. #
  144. proc is3way {} {
  145.     global host_triplet
  146.     global build_triplet
  147.     
  148.     if ![info exists build_triplet] {
  149.     set build_triplet ${host_triplet}
  150.     }
  151.     verbose "Checking $host_triplet against $build_triplet" 2
  152.     if { "$build_triplet" == "$host_triplet" } {
  153.     return 0
  154.     }
  155.     return 1
  156. }
  157.  
  158. #
  159. # Check host triplet for pattern
  160. #
  161. # With no arguments it returns the triplet string.
  162. #
  163. proc ishost { pattern } {
  164.     global host_triplet
  165.     
  166.     if [string match "" $pattern] {
  167.     return $host_triplet
  168.     }
  169.     verbose "Checking pattern \"$pattern\" with $host_triplet" 2
  170.     
  171.     if [string match "$pattern" $host_triplet] {
  172.     return 1
  173.     } else {
  174.     return 0
  175.     }
  176. }
  177.  
  178. #
  179. # Check target triplet for pattern
  180. #
  181. # With no arguments it returns the triplet string.
  182. # Returns 1 if the target looked for, or 0 if not.
  183. #
  184. proc istarget { args } {
  185.     global target_triplet
  186.     
  187.     # if no arg, return the config string
  188.     if [string match "" $args] {
  189.     if [info exists target_triplet] {
  190.         return $target_triplet
  191.     } else {
  192.         perror "No target configuration names found."
  193.     }
  194.     }
  195.  
  196.     # now check against the cannonical name
  197.     if [info exists target_triplet] {
  198.     verbose "Checking \"$args\" against \"$target_triplet\"" 2
  199.     if [string match "$args" $target_triplet] {
  200.         return 1
  201.     }
  202.     }
  203.  
  204.     # nope, no match
  205.     return 0
  206. }
  207.  
  208. #
  209. # Check to see if we're running the tests in a native environment
  210. #
  211. # Returns 1 if running native, 0 if on a target.
  212. #
  213. proc isnative { } {
  214.     global target_triplet
  215.     global build_triplet
  216.     
  217.     if [string match $build_triplet $target_triplet] {
  218.     return 1
  219.     }
  220.     return 0
  221. }
  222.  
  223. #
  224. # unknown -- called by expect if a proc is called that doesn't exist
  225. #
  226. proc unknown { args } {
  227.     global errorCode
  228.     global errorInfo
  229.     global exit_status
  230.  
  231.     clone_output "ERROR: (DejaGnu) proc \"$args\" does not exist."
  232.     if [info exists errorCode] {
  233.         send_error "The error code is $errorCode\n"
  234.     }
  235.     if [info exists errorInfo] {
  236.         send_error "The info on the error is:\n$errorInfo\n"
  237.     }
  238.  
  239.     set exit_status 1;
  240.     log_and_exit;
  241. }
  242.  
  243. #
  244. # Print output to stdout (or stderr) and to log file
  245. #
  246. # If the --all flag (-a) option was used then all messages go the the screen.
  247. # Without this, all messages that start with a keyword are written only to the
  248. # detail log file.  All messages that go to the screen will also appear in the
  249. # detail log.  This should only be used by the framework itself using pass,
  250. # fail, xpass, xfail, warning, perror, note, untested, unresolved, or
  251. # unsupported procedures.
  252. #
  253. proc clone_output { message } {
  254.     global sum_file
  255.     global all_flag
  256.     
  257.     if { $sum_file != "" } {
  258.     puts $sum_file "$message"
  259.     }
  260.  
  261.     regsub "^\[ \t\]*(\[^ \t\]+).*$" "$message" "\\1" firstword;
  262.     case "$firstword" in {
  263.     {"PASS:" "XFAIL:" "UNRESOLVED:" "UNSUPPORTED:" "UNTESTED:"} {
  264.         if $all_flag {
  265.         send_user "$message\n"
  266.         return "$message"
  267.         } else {
  268.         send_log "$message\n"
  269.         }
  270.     }
  271.     {"ERROR:" "WARNING:" "NOTE:"} {
  272.         send_error "$message\n"
  273.         return "$message"
  274.     }
  275.     default {
  276.         send_user "$message\n"
  277.         return "$message"
  278.     }
  279.     }
  280. }
  281.  
  282. #
  283. # Reset a few counters.
  284. #
  285. proc reset_vars {} {
  286.     global test_names test_counts;
  287.     global warncnt errcnt;
  288.  
  289.     # other miscellaneous variables
  290.     global prms_id
  291.     global bug_id
  292.     
  293.     # reset them all
  294.     set prms_id    0;
  295.     set bug_id    0;
  296.     set warncnt 0;
  297.     set errcnt  0;
  298.     foreach x $test_names {
  299.     set test_counts($x,count) 0;
  300.     }
  301.  
  302.     # Variables local to this file.
  303.     global warning_threshold perror_threshold
  304.     set warning_threshold 3
  305.     set perror_threshold 1
  306. }
  307.  
  308. proc log_and_exit {} {
  309.     global exit_status;
  310.     global tool mail_logs outdir mailing_list;
  311.  
  312.     log_summary total;
  313.     # extract version number
  314.     if {[info procs ${tool}_version] != ""} {
  315.     if {[catch "${tool}_version" output]} {
  316.         warning "${tool}_version failed:\n$output"
  317.     }
  318.     }
  319.     close_logs
  320.     cleanup
  321.     verbose -log "runtest completed at [timestamp -format %c]"
  322.     if $mail_logs {
  323.     mail_file $outdir/$tool.sum $mailing_list "Dejagnu Summary Log"
  324.     }
  325.     remote_close host
  326.     remote_close target
  327.     exit $exit_status
  328. }
  329. #
  330. # Print summary of all pass/fail counts
  331. #
  332. proc log_summary { args } {
  333.     global tool
  334.     global sum_file
  335.     global exit_status
  336.     global mail_logs
  337.     global outdir
  338.     global mailing_list
  339.     global current_target_name
  340.     global test_counts;
  341.     global testcnt;
  342.  
  343.     if { [llength $args] == 0 } {
  344.     set which "count";
  345.     } else {
  346.     set which [lindex $args 0];
  347.     }
  348.  
  349.     if { [llength $args] == 0 } {
  350.     clone_output "\n\t\t=== $tool Summary for $current_target_name ===\n"
  351.     } else {
  352.     clone_output "\n\t\t=== $tool Summary ===\n"
  353.     }
  354.  
  355.     # If the tool set `testcnt', it wants us to do a sanity check on the
  356.     # total count, so compare the reported number of testcases with the
  357.     # expected number.  Maintaining an accurate count in `testcnt' isn't easy
  358.     # so it's not clear how often this will be used.
  359.     if [info exists testcnt] {
  360.     if { $testcnt > 0 } {
  361.         set totlcnt 0;
  362.         # total all the testcases reported
  363.         foreach x { FAIL PASS XFAIL XPASS UNTESTED UNRESOLVED UNSUPPORTED } {
  364.         incr totlcnt test_counts($x,$which);
  365.         }
  366.         set testcnt test_counts(total,$which);
  367.         
  368.         if { $testcnt>$totlcnt || $testcnt<$totlcnt } {
  369.         if { $testcnt > $totlcnt } {
  370.             set mismatch "unreported  [expr $testcnt-$totlcnt]"
  371.         }
  372.         if { $testcnt < $totlcnt } {
  373.             set mismatch "misreported [expr $totlcnt-$testcnt]"
  374.         }
  375.         } else {
  376.         verbose "# of testcases run         $testcnt"
  377.         }
  378.  
  379.         if [info exists mismatch] {
  380.         clone_output "### ERROR: totals do not equal number of testcases run"
  381.         clone_output "### ERROR: # of testcases expected    $testcnt"
  382.         clone_output "### ERROR: # of testcases reported    $totlcnt"
  383.         clone_output "### ERROR: # of testcases $mismatch\n"
  384.         }
  385.     }
  386.     }
  387.     foreach x { PASS FAIL XPASS XFAIL UNRESOLVED UNTESTED UNSUPPORTED } {
  388.     set val $test_counts($x,$which);
  389.     if { $val > 0 } {
  390.         set mess "# of $test_counts($x,name)";
  391.         if { [string length $mess] < 24 } {
  392.         append mess "\t";
  393.         }
  394.         clone_output "$mess\t$val";
  395.     }
  396.     }
  397. }
  398.  
  399. #
  400. # Close all open files, remove temp file and core files
  401. #
  402. proc cleanup {} {
  403.     global sum_file
  404.     global exit_status
  405.     global done_list
  406.     global subdir
  407.     
  408.     #catch "exec rm -f [glob xgdb core *.x *.o *_soc a.out]"
  409.     #catch "exec rm -f [glob -nocomplain $subdir/*.o $subdir/*.x $subdir/*_soc]"
  410. }
  411.  
  412. #
  413. # Setup a flag to control whether a failure is expected or not
  414. #
  415. # Multiple target triplet patterns can be specified for targets
  416. # for which the test fails.  A decimal number can be specified,
  417. # which is the PRMS number.
  418. #
  419. proc setup_xfail { args } {
  420.     global xfail_flag
  421.     global xfail_prms
  422.     
  423.     set xfail_prms 0
  424.     set argc [ llength $args ]
  425.     for { set i 0 } { $i < $argc } { incr i } {
  426.     set sub_arg [ lindex $args $i ]
  427.     # is a prms number. we assume this is a number with no characters
  428.     if [regexp "^\[0-9\]+$" $sub_arg] { 
  429.         set xfail_prms $sub_arg
  430.         continue
  431.     }
  432.     if [istarget $sub_arg] {
  433.         set xfail_flag 1
  434.         continue
  435.     }
  436.     }
  437. }
  438.  
  439.  
  440. # check to see if a conditional xfail is triggered
  441. #    message {targets} {include} {exclude}
  442. #              
  443. #
  444. proc check_conditional_xfail { args } {
  445.     global compiler_flags
  446.  
  447.     set all_args [lindex $args 0]
  448.  
  449.     set message [lindex $all_args 0]
  450.  
  451.     set target_list [lindex $all_args 1]
  452.     verbose "Limited to targets: $target_list" 3
  453.  
  454.     # get the list of flags to look for
  455.     set includes [lindex $all_args 2]
  456.     verbose "Will search for options $includes" 3
  457.  
  458.     # get the list of flags to exclude
  459.     if { [llength $all_args] > 3 } {
  460.     set excludes [lindex $all_args 3]
  461.     verbose "Will exclude for options $excludes" 3
  462.     } else {
  463.     set excludes ""
  464.     }
  465.     
  466.     # loop through all the targets, checking the options for each one
  467.     verbose "Compiler flags are: $compiler_flags" 2
  468.     
  469.     set incl_hit 0
  470.     set excl_hit 0
  471.     foreach targ $target_list {
  472.     if [istarget $targ] {
  473.         # look through the compiler options for flags we want to see
  474.         # this is really messy cause each set of options to look for
  475.         # may also be a list. We also want to find each element of the
  476.         # list, regardless of order to make sure they're found.
  477.         # So we look for lists in side of lists, and make sure all 
  478.         # the elements match before we decide this is legit.
  479.         for { set i 0 } { $i < [llength $includes] } { incr i } {
  480.         set incl_hit 0
  481.         set opt [lindex $includes $i]
  482.         verbose "Looking for $opt to include in the compiler flags" 2
  483.         foreach j "$opt" {
  484.             if [string match "* $j *" $compiler_flags] {
  485.             verbose "Found $j to include in the compiler flags" 2
  486.             incr incl_hit
  487.             }
  488.         }
  489.         # if the number of hits we get is the same as the number of
  490.         # specified options, then we got a match
  491.         if {$incl_hit == [llength $opt]} {
  492.             break
  493.         } else {
  494.             set incl_hit 0
  495.         }
  496.         }
  497.         # look through the compiler options for flags we don't
  498.         # want to see
  499.         for { set i 0 } { $i < [llength $excludes] } { incr i } {
  500.         set excl_hit 0
  501.         set opt [lindex $excludes $i]
  502.         verbose "Looking for $opt to exclude in the compiler flags" 2
  503.         foreach j "$opt" {
  504.             if [string match "* $j *" $compiler_flags] {
  505.             verbose "Found $j to exclude in the compiler flags" 2
  506.             incr excl_hit
  507.             }
  508.         }
  509.         # if the number of hits we get is the same as the number of
  510.         # specified options, then we got a match
  511.         if {$excl_hit == [llength $opt]} {
  512.             break
  513.         } else {
  514.             set excl_hit 0
  515.         }
  516.         }
  517.  
  518.         # if we got a match for what to include, but didn't find any reasons
  519.         # to exclude this, then we got a match! So return one to turn this into
  520.         # an expected failure.
  521.         if {$incl_hit && ! $excl_hit } {
  522.         verbose "This is a conditional match" 2
  523.         return 1
  524.         } else {
  525.         verbose "This is not a conditional match" 2
  526.         return 0
  527.         }
  528.     }
  529.     }
  530.     return 0
  531. }
  532.  
  533. #
  534. # Clear the xfail flag for a particular target
  535. #
  536. proc clear_xfail { args } {
  537.     global xfail_flag
  538.     global xfail_prms
  539.     
  540.     set argc [ llength $args ]
  541.     for { set i 0 } { $i < $argc } { incr i } {
  542.     set sub_arg [ lindex $args $i ]
  543.     case $sub_arg in {
  544.         "*-*-*" {            # is a configuration triplet
  545.         if [istarget $sub_arg] {
  546.             set xfail_flag 0
  547.             set xfail_prms 0
  548.         }
  549.         continue
  550.         }
  551.     }
  552.     }
  553. }
  554.  
  555. #
  556. # Record that a test has passed or failed (perhaps unexpectedly)
  557. #
  558. # This is an internal procedure, only used in this file.
  559. #
  560. proc record_test { type message args } {
  561.     global exit_status
  562.     global prms_id bug_id
  563.     global xfail_flag xfail_prms
  564.     global errcnt warncnt
  565.     global warning_threshold perror_threshold
  566.     global pf_prefix
  567.  
  568.     if { [llength $args] > 0 } {
  569.     set count [lindex $args 0];
  570.     } else {
  571.     set count 1;
  572.     }
  573.     if [info exists pf_prefix] {
  574.     set message [concat $pf_prefix " " $message];
  575.     }
  576.  
  577.     # If we have too many warnings or errors,
  578.     # the output of the test can't be considered correct.
  579.     if { $warning_threshold > 0 && $warncnt >= $warning_threshold
  580.      || $perror_threshold > 0 && $errcnt >= $perror_threshold } {
  581.     # Reset these first to prevent infinite recursion.
  582.     set warncnt 0
  583.     set errcnt  0
  584.     unresolved $message
  585.     return
  586.     }
  587.  
  588.     incr_count $type;
  589.  
  590.     switch $type {
  591.     PASS {
  592.         if $prms_id {
  593.         set message [concat $message "\t(PRMS $prms_id)"]
  594.         }
  595.     }
  596.     FAIL {
  597.         set exit_status 1
  598.         if $prms_id {
  599.         set message [concat $message "\t(PRMS $prms_id)"]
  600.         }
  601.     }
  602.     XPASS {
  603.         set exit_status 1
  604.         if { $xfail_prms != 0 } {
  605.         set message [concat $message "\t(PRMS $xfail_prms)"]
  606.         }
  607.     }
  608.     XFAIL {
  609.         if { $xfail_prms != 0 } {
  610.         set message [concat $message "\t(PRMS $xfail_prms)"]
  611.         }
  612.     }
  613.     UNTESTED {
  614.         # The only reason we look at the xfail stuff is to pick up
  615.         # `xfail_prms'.
  616.         if { $xfail_flag && $xfail_prms != 0 } {
  617.         set message [concat $message "\t(PRMS $xfail_prms)"]
  618.         } elseif $prms_id {
  619.         set message [concat $message "\t(PRMS $prms_id)"]
  620.         }
  621.     }
  622.     UNRESOLVED {
  623.         set exit_status 1
  624.         # The only reason we look at the xfail stuff is to pick up
  625.         # `xfail_prms'.
  626.         if { $xfail_flag && $xfail_prms != 0 } {
  627.         set message [concat $message "\t(PRMS $xfail_prms)"]
  628.         } elseif $prms_id {
  629.         set message [concat $message "\t(PRMS $prms_id)"]
  630.         }
  631.     }
  632.     UNSUPPORTED {
  633.         # The only reason we look at the xfail stuff is to pick up
  634.         # `xfail_prms'.
  635.         if { $xfail_flag && $xfail_prms != 0 } {
  636.         set message [concat $message "\t(PRMS $xfail_prms)"]
  637.         } elseif $prms_id {
  638.         set message [concat $message "\t(PRMS $prms_id)"]
  639.         }
  640.     }
  641.     default {
  642.         perror "record_test called with bad type `$type'"
  643.         set errcnt 0
  644.         return
  645.     }
  646.     }
  647.  
  648.     if $bug_id {
  649.     set message [concat $message "\t(BUG $bug_id)"]
  650.     }
  651.  
  652.     global multipass_name
  653.     if { $multipass_name != "" } {
  654.     clone_output "$type: $multipass_name: $message"
  655.     } else {
  656.     clone_output "$type: $message"
  657.     }
  658.     
  659.     # Reset these so they're ready for the next test case.  We don't reset
  660.     # prms_id or bug_id here.  There may be multiple tests for them.  Instead
  661.     # they are reset in the main loop after each test.  It is also the
  662.     # testsuite driver's responsibility to reset them after each testcase.
  663.     set warncnt 0
  664.     set errcnt 0
  665.     set xfail_flag 0
  666.     set xfail_prms 0
  667. }
  668.  
  669. #
  670. # Record that a test has passed
  671. #
  672. proc pass { message } {
  673.     global xfail_flag
  674.  
  675.     # if we have a conditional xfail setup, then see if our compiler flags match
  676.     if [uplevel {info exists compiler_conditional_xfail_data}] {
  677.     if [uplevel {check_conditional_xfail $compiler_conditional_xfail_data}] {
  678.         set xfail_flag 1
  679.     }
  680.     uplevel {unset compiler_conditional_xfail_data}
  681.     }
  682.     
  683.     if $xfail_flag {
  684.     record_test XPASS $message
  685.     } else {
  686.     record_test PASS $message
  687.     }
  688. }
  689.  
  690. #
  691. # Record that a test has failed
  692. #
  693. proc fail { message } {
  694.     global xfail_flag
  695.  
  696.     # if we have a conditional xfail setup, then see if our compiler flags match
  697.     if [uplevel {info exists compiler_conditional_xfail_data}] {
  698.     if [uplevel {check_conditional_xfail $compiler_conditional_xfail_data}] {
  699.         set xfail_flag 1
  700.     }
  701.     uplevel {unset compiler_conditional_xfail_data}
  702.     }
  703.  
  704.     if $xfail_flag {
  705.     record_test XFAIL $message
  706.     } else {
  707.     record_test FAIL $message
  708.     }
  709. }
  710.  
  711. #
  712. # Record that a test has passed unexpectedly
  713. #
  714. proc xpass { message } {
  715.     record_test XPASS $message
  716. }
  717.  
  718. #
  719. # Record that a test has failed unexpectedly
  720. #
  721. proc xfail { message } {
  722.     record_test XFAIL $message
  723. }
  724.  
  725. #
  726. # Set warning threshold
  727. #
  728. proc set_warning_threshold { threshold } {
  729.     set warning_threshold $threshold
  730. }
  731.  
  732. #
  733. # Get warning threshold
  734. #
  735. proc get_warning_threshold { } {
  736.     return $warning_threshold
  737. }
  738.  
  739. #
  740. # Prints warning messages
  741. # These are warnings from the framework, not from the tools being tested.
  742. # It takes a string, and an optional number and returns nothing.
  743. #
  744. proc warning { args } {
  745.     global warncnt
  746.  
  747.     if { [llength $args] > 1 } {
  748.     set warncnt [lindex $args 1]
  749.     } else {
  750.     incr warncnt
  751.     }
  752.     set message [lindex $args 0]
  753.     
  754.     clone_output "WARNING: $message"
  755.  
  756.     global errorInfo
  757.     if [info exists errorInfo] {
  758.     unset errorInfo
  759.     }
  760. }
  761.  
  762. #
  763. # Prints error messages
  764. # These are errors from the framework, not from the tools being tested. 
  765. # It takes a string, and an optional number and returns nothing.
  766. #
  767. proc perror { args } {
  768.     global errcnt
  769.  
  770.     if { [llength $args] > 1 } {
  771.     set errcnt [lindex $args 1]
  772.     } else {
  773.     incr errcnt
  774.     }
  775.     set message [lindex $args 0]
  776.     
  777.     clone_output "ERROR: $message"
  778.  
  779.     global errorInfo
  780.     if [info exists errorInfo] {
  781.     unset errorInfo
  782.     }
  783. }
  784.  
  785. #
  786. # Prints informational messages
  787. #
  788. # These are messages from the framework, not from the tools being tested.
  789. # This means that it is currently illegal to call this proc outside
  790. # of dejagnu proper.
  791. #
  792. proc note { message } {
  793.     clone_output "NOTE: $message"
  794.  
  795.     # ??? It's not clear whether we should do this.  Let's not, and only do
  796.     # so if we find a real need for it.
  797.     #global errorInfo
  798.     #if [info exists errorInfo] {
  799.     #    unset errorInfo
  800.     #}
  801. }
  802.  
  803. #
  804. # untested -- mark the test case as untested
  805. #
  806. proc untested { message } {
  807.     record_test UNTESTED $message
  808. }
  809.  
  810. #
  811. # Mark the test case as unresolved
  812. #
  813. proc unresolved { message } {
  814.     record_test UNRESOLVED $message
  815. }
  816.  
  817. #
  818. # Mark the test case as unsupported
  819. #
  820. # Usually this is used for a test that is missing OS support.
  821. #
  822. proc unsupported { message } {
  823.     record_test UNSUPPORTED $message
  824. }
  825.  
  826. #
  827. # Set up the values in the test_counts array (name and initial totals).
  828. #
  829. proc init_testcounts { } {
  830.     global test_counts test_names;
  831.     set test_counts(TOTAL,name) "testcases run"
  832.     set test_counts(PASS,name) "expected passes"
  833.     set test_counts(FAIL,name) "unexpected failures"
  834.     set test_counts(XFAIL,name) "expected failures"
  835.     set test_counts(XPASS,name) "unexpected successes"
  836.     set test_counts(WARNING,name) "warnings"
  837.     set test_counts(ERROR,name) "errors"
  838.     set test_counts(UNSUPPORTED,name) "unsupported tests"
  839.     set test_counts(UNRESOLVED,name) "unresolved testcases"
  840.     set test_counts(UNTESTED,name) "untested testcases"
  841.     set j "";
  842.  
  843.     foreach i [lsort [array names test_counts]] {
  844.     regsub ",.*$" "$i" "" i;
  845.     if { $i == $j } {
  846.         continue;
  847.     }
  848.     set test_counts($i,total) 0;
  849.     lappend test_names $i;
  850.     set j $i;
  851.     }
  852. }
  853.  
  854. #
  855. # Increment NAME in the test_counts array; the amount to increment can be
  856. # is optional (defaults to 1).
  857. #
  858. proc incr_count { name args } {
  859.     global test_counts;
  860.  
  861.     if { [llength $args] == 0 } {
  862.     set count 1;
  863.     } else {
  864.     set count [lindex $args 0];
  865.     }
  866.     if [info exists test_counts($name,count)] {
  867.     incr test_counts($name,count) $count;
  868.     incr test_counts($name,total) $count;
  869.     } else {
  870.     perror "$name doesn't exist in incr_count"
  871.     }
  872. }
  873.  
  874.  
  875. #
  876. # Create an exp_continue proc if it doesn't exist
  877. #
  878. # For compatablity with old versions.
  879. #
  880. global argv0
  881. if ![info exists argv0] {
  882.     proc exp_continue { } {
  883.     continue -expect
  884.     }
  885. }
  886.